package dbi.org.model;

import java.util.ArrayList;

import dbi.org.exception.TypeDoesntExistsException;
import dbi.org.exception.ValueCannotBeEmptyException;
import dbi.org.exception.ValueNotFoundException;

public class Column {

	private String name;
	private String tableName;
	private String dbName;
	private Type columntype;
	private Boolean mandatory;
	/**
	 * Constructor van veld
	 * @param name Naam van het veld
	 * @param table Tabel waar het veld instaat
	 * @param db De database waar het veld instaat
	 * @param type Het type van het veld
	 * @param mandatory Of het null kan zijn
	 */
	public Column(String name, String tableName, String dbName, Type type, Boolean mandatory) {
		this.name = name;
		this.tableName = tableName;
		this.dbName = dbName;
		this.columntype = type;
		this.mandatory = mandatory;
		//this.values = new ArrayList<String>();
	}
	
	public Column(String name, String tableName, String dbName, String eenType, Boolean eenIsNull) throws TypeDoesntExistsException {
		this.name = name;
		this.tableName = tableName;
		this.dbName = dbName;
		this.mandatory = eenIsNull;
		
		if(eenType.contentEquals("VARCHAR")){
			this.columntype = Type.VARCHAR;
		}else if (eenType.contentEquals("INTEGER")) {
			this.columntype = Type.INTEGER;
		}else if (eenType.contentEquals("BOOLEAN")){
			this.columntype = Type.BOOLEAN;
		}else{
			throw new TypeDoesntExistsException(eenType);
		}
		//this.values = new ArrayList<String>();
		
		
	}
	
	
	/**
	 * @return the tabel
	 */
	public String getTableName() {
		return tableName;
	}
	/**
	 * @param table the tabel to set
	 */
	public void setTable(String tableName) {
		this.tableName = tableName;
	}	




	public String getDbName() {
		return dbName;
	}

	public void setDbName(String dbName) {
		this.dbName = dbName;
	}

	/**
	 * @return the naam
	 */
	public String getName() {
		return name;
	}


	/**
	 * @param naam the naam to set
	 */
	public void setName(String naam) {
		this.name = naam;
	}


	/**
	 * @return the columntype
	 */
	public Type getColumntype() {
		return columntype;
	}


	/**
	 * @param columntype the columntype to set
	 */
	public void setColumntype(Type columntype) {
		this.columntype = columntype;
	}


	/**
	 * @return the mandatory
	 */
	public Boolean getMandatory() {
		return mandatory;
	}


	/**
	 * @param mandatory the mandatory to set
	 */
	public void setMandatory(Boolean mandatory) {
		this.mandatory = mandatory;
	}

//	public ArrayList<String> getValues(){
//		return values;
//	}
//	
//	public void addValue(String value) throws ValueCannotBeEmptyException{
//		if(value.equals("") && mandatory == true){
//			throw new ValueCannotBeEmptyException(this.name);
//		}else{
//			values.add(value);
//		}
//	}
//	
//	public String findValue(String value) throws ValueNotFoundException{
//		
//		int index = values.indexOf(value);
//		
//		if(index == -1)
//			throw new ValueNotFoundException(value);
//
//		return values.get(index);
//	}


}
